package personnal.jonat;

import java.util.Properties;

import org.apache.commons.lang3.StringUtils;

public class PropertiesUtils {

	public static int defaultInt(Properties properties, String key, int defaultValue) {
		String propertyValue = properties.getProperty(key);
		if (propertyValue != null) {
			return Integer.parseInt(propertyValue);
		}
		return defaultValue;
	}

	public static short defaultShort(Properties properties, String key, short defaultValue) {
		String propertyValue = properties.getProperty(key);
		if (propertyValue != null) {
			return Short.parseShort(propertyValue);
		}
		return defaultValue;
	}

	public static String defaultString(Properties properties, String key, String defaultValue) {
		return StringUtils.defaultString(properties.getProperty(key), defaultValue);
	}

}
